package com.lagou;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();

        Set<HostAndPort> jedisClusterNodes = new HashSet<>();

        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7001));
        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7002));
        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7003));
        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7004));
        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7005));
        jedisClusterNodes.add(new HostAndPort("192.168.56.21", 7006));

        JedisCluster jc = new JedisCluster(jedisClusterNodes, config);

        jc.set("name:001", "zhangfei");

        String value = jc.get("name:001");

        System.out.println("value:" + value);
    }
}
